package com.sudoku.observer;

import java.util.ArrayList;

public class Subject {
	private ArrayList<Observer> observers;
	private int numObservers;
	
	public Subject(){
		observers=new ArrayList<Observer>();
		numObservers=0;
	}

	public void addObserver(Observer o) {
		observers.add(o);
		numObservers++;
	}

	public void removeObserver(Observer o) {
		observers.remove(o);
		numObservers--;
	}

	public void notify(Event event) {
		for (int i = 0; i < numObservers; i++) {
			observers.get(i).onNotify(event);
		}
	}

}
